//
//  GRGoodDetailPageModel.m
//  YC_GRice
//
//  Created by luojinrong11 on 2018/8/31.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GRGoodDetailPageModel.h"

@implementation GRGoodDetailPageModel
+ (NSDictionary *)modelCustomPropertyMapper{
    return @{
             @"content":@"description"
             };
}

- (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic{
    
    NSArray* commentArr = dic[@"commentList"];
    if (Array(commentArr)) {
        NSMutableArray * commentListArr = [NSMutableArray array];
        
        for (NSDictionary * commentDic in commentArr) {
            GRStoreCommentModel * commentModel = [GRStoreCommentModel yy_modelWithDictionary:commentDic];
            [commentListArr addObject:commentModel];
        }
        self.commentList = commentListArr;
    }
    
    NSArray *discoutArr = dic[@"detail"];
    if (Array(discoutArr)) {
        NSMutableArray * countArr = [NSMutableArray array];
        for (NSDictionary *detailDic in discoutArr) {
            GRGoodCountModel * countModel = [[GRGoodCountModel alloc]init];
            countModel.isTitle = YES;
            countModel.title = detailDic[@"title"];
            [countArr addObject:countModel];
            for (NSString * goodName in detailDic[@"items"]) {
                GRGoodCountModel * countModel = [[GRGoodCountModel alloc]init];
                countModel.isTitle = NO;
                countModel.title = goodName;
                [countArr addObject:countModel];
            }
        }
        self.goodArr = countArr;
    }
    NSArray * buyNoticeArr = dic[@"buyNotice"];
    if (Array(buyNoticeArr)) {
        NSMutableArray * noticeArr = [NSMutableArray array];
        for (NSDictionary * buyNoticeDic in buyNoticeArr) {
            GRGoodDetailMsgModel *buyNoticeModel = [GRGoodDetailMsgModel yy_modelWithDictionary:buyNoticeDic];
            [noticeArr addObject:buyNoticeModel];
        }
        self.buyNotice = noticeArr;
    }
    NSArray * applyStoreArr = dic[@"applyStore"];
    if (Array(applyStoreArr)) {
        NSMutableArray * applyStore = [NSMutableArray array];
        for (NSDictionary * dic  in applyStoreArr) {
            GRGoodDetailMsgModel *applyStoreModel = [GRGoodDetailMsgModel yy_modelWithDictionary:dic];
            [ applyStore addObject:applyStoreModel];
        }
        self.applyStore = applyStore;
    }

    return YES;
}




// 如果实现了该方法，则处理过程中会忽略该列表内的所有属性
+ (NSArray *)modelPropertyBlacklist {
    return @[
             @"commentList",
             @"detail",
             @"buyNotice",
             @"applyStore",
             @"goodArr",
            
             ];
}
-(CGFloat)ContentCellHeight{
    CGFloat height = 90;
    if (self.title) {
            height += [self.title boundingRectWithSize:CGSizeMake(KscreenWidth-32, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18]} context:nil].size.height;
    }
    if (self.content) {
                    height += [self.content boundingRectWithSize:CGSizeMake(KscreenWidth-32, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:12]} context:nil].size.height+5;
    }
    return height;
    
}

@end


@implementation GRGoodDetailMsgModel

@end
@implementation GRGoodCountModel

@end

